$(function() {
    var peopleContent =
        "<div class='senseContent' id='senseDemo'>" +
        "<div><h5>宋卫国&nbsp; </h5><p>湖里水库管理所 &nbsp; &nbsp;  状态：<span>在线</span></p></div>" +
        "<div><h6>当前位置：</h6><p>湖里区仙岳路金三小学</p></div>" +
        "<div><h6>最近在线：</h6><p>2017-01-21 08:45</p></div>" +
        "<div><h6>手机号码：</h6><p>18031561545</p></div>" +
        "<div><h6>今日上报数/总上报数：</h6><p>2/226</p></div>" +
        "<div><h6>今日完成数/总上报数：</h6><p>2/226</p></div>" +
        "<div><h6>坐标：</h6><p class='coordinate'>北纬N24.23.55.55 东经E118.56 2152</p></div>" +
        "</div>";
    var map = new BMap.Map("map"); // 百度地图API定位一个厦门大位置功能
    var point = new BMap.Point(118.10388605, 24.48923061);
    var peopleWindow = new BMap.InfoWindow(peopleContent); // 创建信息窗口对象
    map.centerAndZoom(point, 15);
    map.enableScrollWheelZoom();
    //创建传感小图标
    var pt = new BMap.Point(118.10388605, 24.5);
    var myIcon = new BMap.Icon("images/sense.png", new BMap.Size(300, 157));
    var marker = new BMap.Marker(pt, { icon: myIcon }); // 创建标注
    map.addOverlay(marker);
    marker.addEventListener("click", function() {
        this.openInfoWindow(peopleWindow);
        //图片加载完毕重绘infowindow
        document.getElementById('senseDemo').onload = function() {
            peopleWindow.redraw(); //防止在网速较慢，图片未加载时，生成的信息框高度比图片的总高度小，导致图片部分被隐藏
        }
    });


})
